package com.wink_172.adapter;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.RecyclerView;

import com.wink_172.commons.R;
import com.wink_172.commons.databinding.ItemView70Binding;
import com.wink_172.library.adapter.HomeListAdapter;
import com.wink_172.library.model.BaseDataItem;
import com.wink_172.library.model.Constants;
import com.wink_172.library.model.json.FileData;
import com.wink_172.library.utils.CommonUtils;

import org.jetbrains.annotations.NotNull;
import org.xutils.x;

import java.util.List;


public class HBomeListAdapter extends HomeListAdapter{

    public HBomeListAdapter() {
    }

    public HBomeListAdapter(Context context, List<Object> dataList, RecyclerView listview) {
        super(context, dataList, listview);
    }

//    @Override
//    public HomeListAdapter.BaseViewsHolder onCreateViewHolder(ViewGroup parent, int viewType) {
//        HomeListAdapter.BaseViewsHolder viewVolder = null;
//        return viewVolder;
//    }

    public BaseViewsHolder createCustomViewHolder(ViewGroup parent, int viewType) {
        View view = null;

        switch (viewType) {
            case com.wink_172.model.Constants.SCENE_DOWN_LOAD_LIST:
                view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_view70, parent, false);
                return new Dynamic4ViewHolder(view);

            default:
                return null;
        }
    }

    private static final String TAG = "HBomeListAdapter";
    private class Dynamic4ViewHolder extends BaseViewsHolder {

        private ItemView70Binding binding;

        public Dynamic4ViewHolder(View itemView) {
            super(itemView);
            binding = DataBindingUtil.bind(itemView);
            binding.contentView.setOnClickListener(this);

        }

        @Override
        public void onClick(@NonNull View v) {
            super.onClick(v);
            Log.e(TAG, "onClick: ====>>" );
            getMCallback().postObject(Constants.EVENT_01);

        }

        @Override
        public void updateContent(Object itemData) {
            BaseDataItem item = (BaseDataItem) itemData;
            setCallback(item.getCallback());

            FileData fileData= (FileData) item.getData();
            binding.contentView.setText(fileData.getName());

        }
    }

}